import jsonp from 'jsonp';
const parseParam = function(param){
    let params = [];
    for (let key in param){
        params.push([key,param[key]])
    }
    let finalurl = params.map(v=>v.join('=')).join('&');
    return finalurl
}

export default (url ,data ,options)=>{
    url += (url.indexOf('?')<0?'?':"&") + parseParam(data)
    return new Promise((resolve,reject)=>{
        jsonp(url,options,(err,data)=>{
            if(err){
                reject(err)
            }else{
                resolve(data)
            }
        })
    })
    
}